package my.jpcap;

import jpcap.JpcapCaptor;
import jpcap.NetworkInterface;
import jpcap.PacketReceiver;

import com.sun.tools.jdi.Packet;

public class JPCap {
	public static void main(String[] args) throws Exception {
		NetworkInterface[] devices = JpcapCaptor.getDeviceList();
		int index = 0;
		if (devices.length > 1)/* 去掉虚拟网卡的处理 */
			index = 0;
		JpcapCaptor captor = JpcapCaptor.openDevice(devices[index], 65535,
				false, 20);
		captor.loopPacket(-1, new Receiver());
	}
}

class Receiver implements PacketReceiver {
	/* 实例receivePacket方法 */
	public void receivePacket(Packet packet) {
		/* 进行简单的处理 */
		System.out.println(packet);
	}

	@Override
	public void receivePacket(jpcap.packet.Packet arg0) {
		// TODO Auto-generated method stub
		
	}
}
